package com.emmy.walnut.ui;


import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;

import com.emmy.walnut.R;

/**
 * @ClassName TipDialog
 * @Description TODO
 * @Author zhouxuan
 * @Date 2020/02/09 10:19
 * @Version 1.0
 */
public class TipDialog extends Dialog {

    public TipDialog(Context context){
        this(context,R.style.DialogBackgroundNull);
    }

    public TipDialog(Context context, int resThemeId){
        super(context, resThemeId);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        init();
    }

    private void init(){
        Window window = getWindow();
        if (window!=null){
            WindowManager.LayoutParams layoutParams = window.getAttributes();
            layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
            window.setAttributes(layoutParams);
        }
    }

    public static class Builder{
        private Context context;

        public Builder(Context context){
            this.context = context;
        }

        public TipDialog create(){
            return create(false);
        }

        public TipDialog create(boolean cancelable){
            TipDialog tipDialog = new TipDialog(context);
            tipDialog.setCancelable(false);
            tipDialog.setContentView(R.layout.dialog_tip);

            return tipDialog;
        }
    }
}
